Problem: The values of $f$, $g$, $h$ and $j$ are 5, 6, 7 and 8, but not necessarily in that order. What is the largest possible value of the sum of the four products $fg$, $gh$, $hj$ and $fj$?
Seeing pairwise products, we consider  \[
(f+g+h+j)^2=f^2+g^2+h^2+j^2+2(fg+fh+fj+gh+gj+hj),
\] so \[
fg+gh+hj+fj=\frac{(f+g+h+j)^2-f^2-g^2-h^2-j^2}{2}-(fh+gj).
\] Since the fraction on the right-hand side does not depend on how the values of $f$, $g$, $h$, and $j$ are assigned, we maximize $fg+gh+hj+fj$ by minimizing $fh+gj$.  Checking the three distinct values for $fh+gj$, we find that $5\cdot8+6\cdot7=82$ is its minimum value.  Therefore, the largest possible value of $fg+gh+hj+fj$ is $\frac{(5+6+7+8)^2-5^2-6^2-7^2-8^2}{2}-82=\boxed{169}$.